<script type="text/javascript">
    var popupWidth = eval('<?php echo isset($popupWidth)? $popupWidth: ''; ?>');
    var popupHeight= eval('<?php echo isset($popupHeight)? $popupHeight: ''; ?>');
    var popupPosition = eval('<?php echo isset($popupPosition)? $popupPosition: ''; ?>');
    $j(function() {
        $("popup").show();
        $j("#popup").dialog($j.extend({}, dialog_options, {
            width: popupWidth,
            position: popupPosition,
            title: "<?php echo $popupTitle; ?>",
            close: function() {
                // ทำลาย div popup ทิ้ง เผื่อการเรียก popup ครั้งต่อไป
                $j("#popup").dialog('destroy');
                $j("#popup").remove();
            }
        }));
        $j("#popup").click(function() {
            // กรณีมีการใช้ Ajax update content ต้องปรับ การ modal form ใหม่
            $j("#popup").dialog("option", "modal", false);
            $j("#popup").dialog("option", "modal", true);
        });
    });
</script>
<?php if (isset($this->passedArgs['callback'])) : ?>
<script type="text/javascript">
    var callback = "<?php echo $this->passedArgs['callback']; ?>";

    popup_click = function(id) {
        $j("#popup").dialog("close");
        if (typeof id == "number") {
            eval(callback + "(" + id + ")");
        } else {
            eval(callback + "('" + id + "')");
        }
    }
</script>
<?php endif; ?>

<div id="popup" title="<?php echo $popupTitle; ?>" style="display: none;">
    <div id="popupContent">
        <?php echo $content_for_layout; ?>
    </div>
</div>